(function($){
    ujs.define('plugin', 'ujs.browser', {    
        /**
         * 获取插件. 
         * @param {Object} pluginName
         */
        getPlugin: function(pluginName) {
            if (navigator.plugins && navigator.plugins.length) {
                for (var i = 0; i < navigator.plugins.length; i++) {
                    if (navigator.plugins[i].name == pluginName) return navigator.plugins[i];
                }
            }
        },
        isPluginInstalled: function(pluginName) {        
            return !! (this.getPlugin(pluginName));
        },
        isAdobePDFPluginInstalled: function() {
            return this.isPluginInstalled('Adobe Acrobat'); 
        },
        isChromePDFViewerInstalled : function(){
            return this.isPluginInstalled('Chrome PDF Viewer'); 
        },
        isPDFReaderInstalled : function(){
            return this.isAdobePDFPluginInstalled() || this.isChromePDFViewerInstalled();
        },
        print: function($ctn) {
            var plugins = window.navigator.plugins;
            for (var i = 0, len = plugins.length; i < len; i++) {
                $ctn.append('<div>' + (i + 1) + '.' + plugins[i]['name'] + '<br/>' + plugins[i]['description'] + '</div><hr/>');
            }
        }
    });
})($);